// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import App from './App'
import Home from './components/HelloFromVux'
import Test from './components/test'
import Shdz from './components/shdz'
import Shdz1 from './components/shdz1'
import Shdz2 from './components/shdz2'
import Wdpq from './components/wdpq'
import Zhuli from './components/zhuli'
import Yhcg from './components/yhcg'
import Pqjs from './components/pqjs'
import Jay_jun from './components/jay_jun'
import Haoxingdi from './components/haoxingdi'
import Haoxingdizhuli from './components/haoxingdizhuli'
import Jfmx from './components/jfmx'
import Yuehuanjilu from './components/yuehuanjilu'
import Xiangqing from './components/xiangqing'
import Gerenzhongxin  from './components/gerenzhongxin'
import Pinqiangguize  from './components/pinqiangguize'
import Pingqiangchenggong  from './components/pingqiangchenggong'
import Yaoqingchenggong  from './components/yaoqingchenggong'
import Querendingdan  from './components/querendingdan'
import Qrmanjianyoufei  from './components/qrmanjianyoufei'
import Lijifaqi  from './components/lijifaqi'
import Pinqiangqingkuang from './components/pinqiangqingkuang'
import Bangzhujilu from './components/bangzhujilu'
import Dindanxiangqing from './components/dindanxiangqing'
import Youduopin from './components/youduopin'
import Gouwuche from './components/gouwuche'
import Jifenshangcheng from './components/jifenshangcheng'
import Jifenshangpingxiangqing from './components/jifenshangpingxiangqing'
import Jifenshangpingxiangqinger from './components/jifenshangpingxiangqinger'
import Tabber from './components/tabber'
import Baocunxindizhi from './components/baocunxindizhi'
import Baocunxindizhi1 from './components/baocunxindizhi1'
import Baocunxindizhi2 from './components/baocunxindizhi2'
import Xiugaidizhi from './components/xiugaidizhi'
import Xiugaidizhi1 from './components/xiugaidizhi1'
import Xiugaidizhi2 from './components/xiugaidizhi2'
import Jifenguize from './components/jifenguize'
import store from './store/store.js'
import axios from 'axios'
import qs from 'qs'
Vue.use(VueRouter)
// 引入微信
import { WechatPlugin } from 'vux'
Vue.use(WechatPlugin)

import { Loading } from 'vux'
//引入公共UI
Vue.component("Loading", Loading )

Vue.filter('datatime', function(n) {
  var date = new Date(n*1000);
  var year = date.getFullYear();
  var month = date.getMonth() + 1;
  var day = date.getDate();
  var hours = date.getHours();
  var minute = date.getMinutes();
  var second = date.getSeconds();
  return  year + '-' + month + '-' + day+ ' ' +hours+ ':' +minute+ ':' +second;
})

axios.defaults.transformRequest= [function (params) {
   return qs.stringify(params, { arrayFormat: 'brackets' })
}];


import { Toast } from 'vux'
Vue.component('Toast',Toast)
const routes = [

{
  path: '/test',
  component: Test
},
{
  path: '/shdz',
  name:'收货地址',
  component: Shdz
}
,
{
  path: '/shdz1',
  name:'收货地址',
  component: Shdz1
},
{
  path: '/shdz2',
  name:'收货地址',
  component: Shdz2
},
{
  path: '/wdpq',
  name:'我的拼抢',
  component: Wdpq
}
,
{
  path: '/zhuli',
  name:'助力成功',
  component: Zhuli
}
,
{
  path: '/yhcg',
  component: Yhcg
}
,
{
  path: '/pqjs',
  name:'邀请好友助力',
  component: Pqjs
}
,
{
  path: '/jay_jun',
  component: Jay_jun
}
,
{
  path: '/jifenguize',
  name:'积分规则',
  component: Jifenguize
}
,
{
  path: '/xiugaidizhi',
  name:'修改地址',
  component: Xiugaidizhi
}
,
{
  path: '/xiugaidizhi1',
  name:'修改地址',
  component: Xiugaidizhi1
}
,
{
  path: '/xiugaidizhi2',
  name:'修改地址',
  component: Xiugaidizhi2
}
,
{
  path: '/haoxingdi',
  name:'助力拼抢',
  component: Haoxingdi
}
,
{
  path: '/haoxingdizhuli',
  component: Haoxingdizhuli
}
,
{
  path: '/jfmx',
  name:'我的积分',
  component: Jfmx
}
,
{
  path: '/yuehuanjilu',
  name:'兑换记录',
  component: Yuehuanjilu
}
,
{
  path: '/pinqiangguize',
  component: Pinqiangguize
}
,
{
  path: '/pingqiangchenggong',
  component: Pingqiangchenggong
}
,
{
  path: '/yaoqingchenggong',
  component: Yaoqingchenggong
}
,
{
  path: '/querendingdan',
  name:'确认订单',
  component: Querendingdan
}
,
{
  path: '/qrmanjianyoufei',
  component: Qrmanjianyoufei
}
,
{
  path: '/lijifaqi',
  name:'发起拼抢',
  component: Lijifaqi
}
,
{
  path: '/pinqiangqingkuang',
  component: Pinqiangqingkuang
}
,
{
  path: '/bangzhujilu',
  name:'帮助记录',
  component: Bangzhujilu
}
,
{
  path: '/dindanxiangqing',
  name:'订单详情',
  component: Dindanxiangqing
}
,
{
  path: '/youduopin',
  component: Youduopin
}
,
{
  path: '/gouwuche',
  name:'购物车',
  component: Gouwuche
}
,
{
  path: '/jifenshangpingxiangqing',
  component: Jifenshangpingxiangqing
}
,
{
  path: '/jifenshangpingxiangqinger',
  component: Jifenshangpingxiangqinger
}
,
{
	  path: '/',
	  component: Tabber,
	  children:[
	  	{
	  		path: '/',
	      name:'拼抢ing',
	  		component: Home
	  	},
	  	{
	  		path: '/jifenshangcheng',
	      name:'积分商城',
	  		component: Jifenshangcheng
	  	},
//	    {
//	      path: '/cart',
//	      name:'订单',
//	      component: Cart
//	    },
	    {
	      path: '/xiangqing',
	      name:'个人中心',
	      component: Xiangqing
	    },
  	  ]
	},
{
  path: '/baocunxindizhi',
  name:'添加地址',
  component: Baocunxindizhi
},
{
  path: '/baocunxindizhi1',
  name:'添加地址',
  component: Baocunxindizhi1
},
{
  path: '/baocunxindizhi2',
  name:'添加地址',
  component: Baocunxindizhi2
}
]


Vue.filter('datatime', function(n) {
  var date = new Date(n*1000);
  var year = date.getFullYear();
  var month = date.getMonth() + 1;
  var day = date.getDate();
  var hours = date.getHours();
  var minute = date.getMinutes();
  var second = date.getSeconds();
  return  year + '-' + month + '-' + day+ ' ' +hours+ ':' +minute+ ':' +second;
})


const router = new VueRouter({
  routes
})


function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1);
        if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
    }
    return "";
}


Vue.prototype.url = 'http://ydp.mylei.cn';
// Vue.prototype.img = 'http://www.ydp.com';
Vue.prototype.cook = getCookie('openids');
// Vue.prototype.cook = 'abc';



FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  store,
  router,
  render: h => h(App),
  watch:{
    "$route" :function (to,from){
      document.title=to.name
    }
  }
}).$mount('#app-box')
